
<template>
  <base-page-view class-name="withdrawDetails">
    <view v-for="(item,index) in listData" :key="index" class="withdrawDetails_list" @click="cancleTip(showIndex)">
      <view class="withdrawDetails_head">
        <view>
          <view class="title">提现流水号</view>
          <view class="date">{{ item.recordId }}</view>
        </view>
        <view v-if="item.auditStatus==='REMIT_SUCCESS'" class="success">
          提现成功
        </view>
        <view v-else-if="item.auditStatus==='REMIT_ERROR'||item.auditStatus==='AUDIT_REFUSE'" class="fail">
          提现失败
          <image src="/static/images/mine/question.png" class="questions" @click.stop="isOrShow(index)" />
          <view v-if="item.isShow" class="tips">
            <view class="tips_view">
              <view>失败原因：</view>
              <view>{{ item.remitRemark }}</view>
            </view>
          </view>
        </view>
        <view v-else class="remiting">
          提现中
        </view>
      </view>
      <view class="withdrawDetails_details">
        <view class="details">
          <view>提现时间</view>
          <view>{{ item.applyTime }}</view>
        </view>
        <view class="details">
          <view>应发(元)</view>
          <view>{{ item.applyFee | formatMoney }}</view>
        </view>
        <view class="details">
          <view>手续费（元）</view>
          <view v-if="item.auditStatus === 'REMIT_SUCCESS'">{{ item.serveFee | formatMoney }}</view>
        </view>
        <view class="details">
          <view>实发（元）</view>
          <view v-if="item.auditStatus === 'REMIT_SUCCESS'">{{ item.realFee | formatMoney }}</view>
        </view>
      </view>
      <!-- <view v-if="item.showDeatil" class="bills_btn">
        <view @click="$navigateTo('/pagesCommission/earnings/billsDetails?id='+item.withdrawId+'&time='+item.month)">
          点击查看明细
          <image src="/static/images/mine/list_more.png" class="bills_list_more" />
        </view>
      </view> -->
    </view>
    <view v-if="listData.length<1" class="empty_view">
      <image src="/static/images/commission/commission-empty.png" class="empty_img" />
      <view class="tit">暂无任何内容</view>
    </view>
    <view v-if="nomore&&listData.length>0" class="nomore">暂无更多数据~</view>
  </base-page-view>
</template>

<script>
import './withdrawDetails.scss'
export default {
  components: {
  },
  data() {
    return {
      pageSize: 10,
      pageNo: 1,
      listData: [],
      nomore: false,
      startTime: 1483200000000,
      endTime: '',
      remark: '',
      showIndex: ''
    }
  },
  created() {
  },
  onLoad(option) {
    this.endTime = Math.ceil(new Date().getTime())
    this.getList()
  },
  onPullDownRefresh() {
    this.pageNo = 1
    this.listData = []
    this.nomore = false
    this.getList()
  },
  onReachBottom() {
    if (this.nomore) return
    this.pageNo += 1
    this.getList()
  },
  onShow() {
  },
  methods: {
    cancleTip(index) {
      for (var i = 0; i < this.listData.length; i++) {
        if (i === index) {
          this.listData[i].isShow = false
        }
      }
    },
    isOrShow(index) {
      this.showIndex = index
      for (var i = 0; i < this.listData.length; i++) {
        if (i === index) {
          this.listData[i].isShow = !this.listData[i].isShow
        } else {
          this.listData[i].isShow = false
        }
      }
    },
    async getList() {
      const res = await this.$api.commissionApi.getTakeRecord({
        userId: this.$store.state.userInfo.uid,
        pageSize: this.pageSize,
        pageNo: this.pageNo,
        startTime: this.startTime,
        endTime: this.endTime
      })
      if (res.code === '000000') {
        setTimeout(function() {
          uni.stopPullDownRefresh()
        }, 500)
        const listArr = res.data.list
        if (listArr.length > 0) {
          listArr.forEach(item => {
            item.isShow = false
          })
        }
        this.listData = this.listData.concat(listArr)

        if (res.data.list.length < this.pageSize) {
          this.nomore = true
        }
        this.remark = res.data.remark
      }
    }
  }
}
</script>
